using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LevelPass : MonoBehaviour
{
    public Text m_LevelPassText;

    public UnityEvent OnLevelPass;

    private void OnTriggerEnter2D(Collider2D other)
    {
        var curScene = SceneManager.GetActiveScene();
        m_LevelPassText.gameObject.SetActive(true);
        OnLevelPass?.Invoke();
        //StartCoroutine(Delay(2f, () =>
        //{
        //    SceneManager.LoadScene(curScene.name);
        //}));
    }

    IEnumerator Delay(float seconds,Action callBack)
    {
        yield return new WaitForSeconds(seconds);
        callBack?.Invoke();
    }

}
